<?php

namespace app\controller\api;

use app\service\UrlService;
use share\controller\ApiBaseController;
use share\service\ContextService;

class UrlController extends ApiBaseController{

    protected $beforeActionList = [
    ];

    public function info_action(){
        $ip = $this->request->ip();
        $vendor = ContextService::getVendor();
        $package = ContextService::getPackageName();
        $version = ContextService::getAppVersion();
        $clientType = ContextService::getClientType();
        $client = ContextService::getClientName();
        $did = ContextService::getDeviceId();
        $data = UrlService::getUrlInfoByFilter($ip,$vendor,$package,$version,$clientType,$client,$did);
        return self::ok(self::formatOutdata($data));
    }

    public static function formatOutdata($data){
        if($data && isset($data['sim'])){ //兼容老的数据字段不规范的输出
            $data['4g'] = $data['sim'];
            unset($data['sim']);
        }
        return $data;
    }

//     设备端
// 1. 查询设备激活码或者烧录注册服务地址 /api/v1/deviceInfo?uid=xxxxxxxxxx&devType=1
// 2. 上报设备序列号与烧录服务地址关联信息 /api/v1/subServer
// 3. 申请设备激活码请求(目前此处仅实用于IPCAM设备) /api/v2/deviceBurn?uid=xxxxxxxxxx&devType=3&burnType=1
// 4. 上报设备写入激活码成功请求(目前此处仅实用于IPCAM设备) /api/v2/deviceBurn
// 5. 强制解绑设备 /api/v2/unbinding
// 6. 上报设备序列号发生改变 /api/v1/serialNo
// 7. SIM卡信息查询 /api/sim/info
// 8. SIM卡绑定信息修改 /api/sim/bindUpdate
// 9. 固件信息查询 URL /api/v1/devFirmware?vendor=xxx&serialNo=xxxx&version=xxxx&buildDate=xxxx&language=xx

    // /**
    //  * 设备端用到的urlKey
    //  */
    // public static function clientUrlKeys(){

    // } 

    // /**
    //  * 应用端(Android IOS)用到的urlKey
    //  */
    // public static function appUrlKeys(){

    // }


}